/*实现阶乘*/
/*method1 递归法（0！=1）*/
function factorialize (num) {
  if (num < 0) {
    return -1;
  } else if (num === 0 || num === 1) {
    return 1;
  } else {
    return (num * factorialize(num - 1));
  }
}

/*method2 for方法*/
/*function factorialize(num) {
  if(num<0){
    return -1;
  }else if(num===0||num===1){
    return 1;
  }else{
   for(let i=num;i>1;i--){
     num*=i-1;
   }
  }
  return num;
}*/
console.log(factorialize(5));


